{extend name='common/common' /}

{block name="style"}
<style>
.float-e-margins .btn {
	margin-bottom: 0;
}
</style>
{/block}

{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>操作日志列表</h5>
        </div>
        <div class="ibox-content">
			<div class="layui-form-item">
				<div class="layui-inline">
					<div class="layui-input-inline">
						<input type="text" name="date" id="date" readonly placeholder="选择时间" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<div class="layui-input-inline">
						<input type="text" name="searchText" id="searchText" placeholder="搜索用户名/操作名" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<div class="layui-input-inline">
						<button type="button" id="search" class="btn btn-info">查询</button>
					</div>
				</div>
			</div>
            <div class="example-wrap">
                <div class="example">
                    <table id="cusTable">
                        <thead>
                        <th class="text-center" data-field="id">ID</th>
                        <th class="text-center" data-field="user_name">用户名</th>
                        <th class="text-center" data-field="u_id">用户ID</th>
                        <th class="text-center" data-field="url">节点路径</th>
                        <th class="text-center" data-field="url_name">节点名称</th>
						<th class="text-center" data-field="c_time">操作时间</th>
                        </thead>
                    </table>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>
{/block}


{block name="script"}
<script type="text/javascript">
    function initTable(searchDate) {
        //先销毁表格
        $('#cusTable').bootstrapTable('destroy');
        //初始化表格,动态从服务器加载数据
        $("#cusTable").bootstrapTable({
            method: "get",  //使用get请求到服务器获取数据
            url: "{:url('log/index')}", //获取数据的地址
            striped: true,  //表格显示条纹
            pagination: true, //启动分页
            pageSize: 20,  //每页显示的记录数
            pageNumber:1, //当前第几页
            pageList: [5, 10, 15, 20, 25],  //记录数可选列表
            sidePagination: "server", //表示服务端请求
            paginationFirstText: "首页",
            paginationPreText: "上一页",
            paginationNextText: "下一页",
            paginationLastText: "尾页",
            queryParamsType : "undefined",
            queryParams: function queryParams(params) {   //设置查询参数
                var param = {
                    pageNumber: params.pageNumber,
                    pageSize: params.pageSize,
                    searchText:$('#searchText').val(),
					searchDate:$('#date').val()
                };
                return param;
            },
            onLoadSuccess: function(res){  //加载成功时执行
                if(111 == res.code){
                    window.location.reload();
                }
                layer.msg("加载成功", {time : 1000});
            },
            onLoadError: function(){  //加载失败时执行
                layer.msg("加载数据失败");
            }
        });
    }

    $(document).ready(function () {
        //调用函数，初始化表格
        initTable();
        //当点击查询按钮的时候执行
        $("#search").bind("click", function(){
			initTable();
		});
    });
$(function(){
	layui.use(['form', 'layedit', 'laydate'], function(){
	  	var form = layui.form,laydate = layui.laydate;

	  	//日期
		laydate.render({
			elem: '#date'
		});
	});
})
</script>
{/block}
